﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

namespace NewSolution
{
    public class FileReadBlock
    {
        private string _filePath;
        private int _bufferSize;

        public FileReadBlock(string filePath, int bufferSize)
        {
            _filePath = filePath;
            _bufferSize = bufferSize;
        }
        public IEnumerable<byte[]> ReadBytes()
        {
            byte[] buffer = new byte[_bufferSize];
            var _fs = File.OpenRead(_filePath);
            while (true)
            {
                int len = _fs.Read(buffer, 0, _bufferSize);

                if (len == 0)
                {
                    yield break;
                }
                yield return buffer[..len];
            }
        }
      
    }
}

